import { sequentSearch } from "./01_顺序查找";
import { binarySearch } from "./02_二分法查找";
const Max = 10000;

const arr = Array(Max)
  .fill(0)
  .map((_, index) => index);

const target = Math.floor(Max / 2);

const time = (fn: any, arr: number[], target: number) => {
  // let start = performance.now();
  let start = new Date().getTime();

  fn(arr, target);
  // let end = performance.now();
  let end = new Date().getTime();

  return end - start;
};

console.log(time(sequentSearch, arr, target), "顺序");

console.log(time(binarySearch, arr, target), "二分");
